package com.lyfx.ly.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyfx.common.utils.PageUtils;
import com.lyfx.common.utils.Query;

import com.lyfx.ly.dao.StudyRouteActivitiyDao;
import com.lyfx.ly.entity.StudyRouteActivitiyEntity;
import com.lyfx.ly.service.StudyRouteActivitiyService;


@Service("studyRouteActivitiyService")
public class StudyRouteActivitiyServiceImpl extends ServiceImpl<StudyRouteActivitiyDao, StudyRouteActivitiyEntity> implements StudyRouteActivitiyService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<StudyRouteActivitiyEntity> page = this.page(
                new Query<StudyRouteActivitiyEntity>().getPage(params),
                new QueryWrapper<StudyRouteActivitiyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void removeByRouteIds(List<Long> asList) {
        QueryWrapper<StudyRouteActivitiyEntity> wrapper = new QueryWrapper<>();
        for (int i = 0; i < asList.size(); i++) {
            wrapper.eq("route_id", asList.get(i));
            if(i!=asList.size()-1){
                wrapper.or();
            }
        }

        this.baseMapper.delete(wrapper);
        //批量删除
    }

}